
import config from '@/utils/conf'
import { integraltype_listAll } from '@/api/integraltype'

class Action {

    async getTypeList(){
        const { data } = await integraltype_listAll({ company_id: localStorage.getItem('companyId') });
        let typeList = []
        if (data.status == 100) {
            typeList = data.data.rows.map(item => {
                return { value: item.id, label: item.integraltype_name }
            })
        }
        return typeList;
    }

    async getToolData(){
        const moduleList = config.moduleList.map((item, i) => {
            return { value: i + 1, label: item }
        }) 
        const actionList = config.actionList.map((item, i) => {
            return { value: i + 1, label: item }
        })
        const close_status = [{ value: 0, label: '取消' }, { value: 1, label: '生效' }]
        const data = [
            {el: 'select', label: '模块', model: 'module', options: moduleList},
            {el: 'select', label: '动作', model: 'action', options: actionList},
            {el: 'input', label: '描述', model: 'behavior_desc'},
            {el: 'select', label: '生效', model: 'close_status', options: close_status},
            {el: 'input', label: '分数', model: 'score'},
            {el: 'select', label: '积分类别', model: 'integraltype_id', options: await this.getTypeList()}
        ]
        return data;
    }

} 

const action = new Action();
export default action;